package ru.urfc.portal.rest;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import ru.urfc.portal.managers.ClientManager;
import ru.urfc.portal.model.admins.User;
import ru.urfc.portal.model.admins.UserSelfUpdate;
import ru.urfc.portal.model.audit.AuditLogEntry;
import ru.urfc.portal.ui.client.Constants;

@Stateless
@Produces({MediaType.APPLICATION_XML, MediaType.TEXT_XML, MediaType.APPLICATION_JSON})
@Path(Constants.USERS + "/{userId}")
public class UsersService extends BaseService {
	
	@EJB ClientManager clientManager; 
	
	@GET
	public User getUser(@PathParam("userId") Long userId) {
		return clientManager.getUserForHimSelf(userId);
	}
	
	@PUT
	public User updateUser(@PathParam("userId") Long userId, UserSelfUpdate userSelfUpdate) {
		return clientManager.updateUser(userId, userSelfUpdate);
	}
	
	@GET
	@Path("audit-log")
	public List<AuditLogEntry> listAuditLog(@PathParam("userId") Long userId) {
		return new ClientService().getSubService().listAuditLog(123L);
	}
	
}